home *** CD-ROM | disk | FTP | other *** search
/ Mac-Source 1994 July / Mac-Source_July_1994.iso / C and C++ / Text⁄Files / ctc 1.6 / tickle.c < prev   
Encoding:
C/C++ Source or Header  |  1994-01-11  |  2.3 KB  |  71 lines  |  [TEXT/KAHL]

  1. /*
  2. ** From: dickie@schaefer.math.wisc.edu (Garth Dickie)
  3. ** Newsgroups: comp.sys.mac.programmer
  4. ** Subject: Re: HOW do I get the finder to update its file information..
  5. ** Message-ID: <1992May22.014427.9977@schaefer.math.wisc.edu>
  6. ** Date: 22 May 92 01:44:27 GMT
  7. ** References: <1992May21.231246.23090@crash.cts.com>
  8. ** Organization: Univ. of Wisconsin Dept. of Mathematics
  9. ** Lines: 58
  10. ** 
  11. ** You need to change the modification date of the parent directory.
  12. ** The routine TickleParent below works for me.  In case you are not
  13. ** using the FSSpec structure, the routine MakeWDSpec will convert
  14. ** a working directory / filename pair to a psuedo-FSSpec.  I use
  15. ** this when the new file manager calls are not available, as the rest
  16. ** of my code passes around FSSpecs.  The code compiles under THINK C
  17. ** 5.0, with the usual headers.
  18. ** 
  19. ** BTW (mild flame) this is simple enough that it's pretty annoying
  20. ** when people don't do it.  Most of the nifty little 'drag-and-drop'
  21. ** utilities that have come around recently forget to do this.  Feel
  22. ** free to use the code below in any way you see fit.
  23. */
  24. #include <Files.h>
  25.  
  26. OSErr TickleParent( FSSpec * child ) {
  27.     CInfoPBRec    pb;
  28.     OSErr         err = noErr;
  29.  
  30.     pb.dirInfo.ioCompletion = 0;
  31.     pb.dirInfo.ioNamePtr = 0;
  32.     pb.dirInfo.ioVRefNum = child->vRefNum;
  33.     pb.dirInfo.ioFDirIndex = -1;              // get info based on the DirID
  34.     pb.dirInfo.ioDrDirID = child->parID;
  35.     
  36.     if(( err = PBGetCatInfoSync( &pb )) != noErr ) return err;
  37.  
  38.     GetDateTime( &pb.dirInfo.ioDrMdDat );
  39.  
  40.     err = PBSetCatInfoSync( &pb );
  41.  
  42.     return err;
  43. }
  44.  
  45. //    err = FSMakeFSSpec(reply.sfFile.vRefNum, reply.sfFile.parID, reply.sfFile.name, &reply.sfFile);
  46.     
  47. OSErr MakeWDSpec( FSSpec *spec, short vRefNum, Str63 name ) {
  48.     WDPBRec        parameter;
  49.     Size        length;
  50.     OSErr        err;
  51.     short        nameLen;
  52.     
  53.     parameter.ioCompletion = 0L;
  54.     parameter.ioNamePtr = 0L;
  55.     parameter.ioVRefNum = vRefNum;
  56.     parameter.ioWDIndex = 0;
  57.     parameter.ioWDProcID = 0;
  58.     parameter.ioWDVRefNum = 0;
  59.  
  60.     err = PBGetWDInfoSync( ¶meter );
  61.      
  62.     spec->vRefNum = parameter.ioWDVRefNum;
  63.     spec->parID = parameter.ioWDDirID;
  64.        nameLen = name[0];
  65.     length = (( nameLen < sizeof spec->name - 1 ) ? nameLen : sizeof spec->name -1);
  66.     BlockMove( name + 1, spec->name + 1, length );
  67.     *spec->name = length;
  68.     
  69.     return err;
  70. }
  71.